import './new_role.html';


Template.new_role.events({
	'submit .new-role-add'(event) {
	    event.preventDefault();

	    const target = event.target;
	    const name = target.getElementsByTagName("input")[0];
		const weight = target.getElementsByTagName("input")[1];

	    Meteor.call('roles.insert', name.value, weight.value, (error) => {
	      if (error) {
	        alert(error.error);
	      } else {
	        name.value = '';
					weight.value = '';
	        $('#new-modal').modal('hide');
					FlashMessages.sendSuccess("角色创建成功");
	      }
	    });

	  },
});